<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title></title>
	</head>
	<script src="__INS__/js/plugins/socket.io/socket.io.js"></script>
	<script src="__INS__/js/jquery-2.1.1.js"></script>
	<script type="text/javascript">
		function get_push() {
			$.getJSON("{:url('push/server')}", function(ret) {
				if (ret.status) {
					$content = eval('(' + ret.data.data + ')');
					window.parent.layui.push_info($content);
				}
				if (ret.status > 0) {
					get_push();
				}
			});
		}

		$(document).ready(function() {
			get_push();
			// 连接服务端
			var socket = io('http://' + document.domain + ':2120');
			// 连接后登录
			socket.on('connect', function() {
				socket.emit('login', '{:get_user_id()}');
			});
			// 后端推送来消息时
			socket.on('new_msg', function(msg) {
				get_push();
			});
		});
	</script>

</html>
